package com.sykj.springboot.controller;

import com.sykj.springboot.common.entity.DataResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.sykj.springboot.entity.User;
import com.sykj.springboot.service.UserService;

@RestController
@RequestMapping("user")
public class UserController {

	@Autowired
	private UserService userService;

	@GetMapping("getUserById/{id}")
	public User getUserById(@PathVariable("id")String id) {
		return userService.getUserById(id);
	}


	@RequestMapping("addUser")
	public DataResponse addUser(User user) {
        DataResponse dataResponse = new DataResponse();
        boolean b = false;
        try {
            b = userService.insertUserInfo(user);
        } catch (Exception e) {
            e.printStackTrace();
        }
        dataResponse.setData(b);
        return dataResponse;
	}

}
